<?php
class Home extends Doctrine_Record {
    public function setTableDefinition() {
        $this->setTableName('home');
    }
    
    public function setUp(){
        $this->hasMany('Imagen as imagenes', array(
            'local' => 'id',
            'foreign' => 'id_home'
        ));
    }
    
    public static function getInstance () {
        return Doctrine::getTable('Home')->find(1);
    }
    
    public function imagenes () {
        $q = Doctrine_Query::create()
            ->select('i.*')
            ->from('Imagen i')
            ->innerJoin('i.home h')
            ->where('h.id = '.$this->id)
            ->orderBy('i.orden');
        return $q->execute();
    }
}
?>